package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.system.domain.TbComingOutLog;
import com.ruoyi.system.domain.vo.ComingOutLogRequest;
import com.ruoyi.system.domain.vo.ComingOutVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ComingOutLogMapper extends BaseMapper<TbComingOutLog> {

    /**
     * 分页查询操作日志
     * @param page 分页参数
     * @param categoryId 分类ID
     * @param operationType 操作类型
     * @return 分页数据
     */
    @Select("<script>" +
            "SELECT * FROM tb_coming_out_log WHERE del_flag = '0' " +
            "<if test='categoryId != null'> AND category_id = #{categoryId} </if>" +
            "<if test='operationType != null'> AND operation_type = #{operationType} </if>" +
            "ORDER BY create_time DESC" +
            "</script>")
    Page<TbComingOutLog> selectLogPage(Page<TbComingOutLog> page,
                                       @Param("categoryId") Long categoryId,
                                       @Param("operationType") Integer operationType);

    Page<ComingOutVO> selectComingOutLog(
            @Param("page") Page<ComingOutVO> page,
            @Param("startTime") String startTime,
            @Param("endTime") String endTime,
            @Param("categoryIds") List<Long> categoryIds
    );

    List<ComingOutVO> getComingOutLogForExport( @Param("startTime") String startTime,
                                                @Param("endTime") String endTime,
                                                @Param("categoryIds") List<Long> categoryIds);
}
